import * as actionTypes from "./constants";
import {
  getTopBanners,
  getHotRecommends
} from "network/recommend";

export const changeTopBannersAction = (res) => {
  return {
    type:actionTypes.CHANGE_TOP_BANNERS,
    topBanners:res.banners
  }
}

export const getTopBannersAction = () => {
    return async ( dispatch) => {
      const {data:res} = await getTopBanners();
      dispatch(changeTopBannersAction(res));
    }
}

export const changeHotRecommendsAction = (res ) => {
  return {
    type:actionTypes.CHANGE_HOT_RECOMMEND,
    hotRecommends:res.result
  }
}

export const getHotRecommendsAction = (limit) =>{
  return async (dispatch ) => {
    const { data :res } = await getHotRecommends(limit);
    dispatch(changeHotRecommendsAction(res));
  }
}
